<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>bui-ssm快速开发框架</title>
<head th:include="source::header"></head>
<style>
body {
	position: relative;
}

body>div {
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
}
._alert_msg{
	float:right;
	line-height: 32px;	
	padding-right: 14px;
	cursor: pointer;
}
._alert_msg span{padding: 0 3px;}

._alert_num{color:red;}


</style>
</head>
<body>
	<div id="header" class="index2_header_shadow">
		<h5>
			<div class="header_logo"></div>
			bui-ssm快速开发框架 v-0.0.1
		</h5>
		<div id="header_menu_wrap"></div>
		<div id="theme_ops">
	    	<a id='index'>风格1</a> <a id='index2'>风格2</a>  <a id='index3'>风格3</a>
	    </div>
		<div id="user_info">
			<span><i
				style="padding-right: 6px; font-size: 1.5em; color: #fff;"
				class='fa fa-user-circle-o'></i></span> <span class="_user_name">[(${loginUser})]</span>
		</div>
		<div id="logout" th:title="${Lang.common_logout}">
			<i class="fa fa-logout-1"></i>
		</div>
	</div>
	<div id="main_body" class="k_box_size index2_main_body">
		<div id="index2_left_menu" class="k_box_size">
			<div id="index2_menu_nav" class="k_box_size"><i class="fa fa fa-desktop"></i>系统菜单</div>
			<div id="index2_menu_ul" class="k_box_size"></div>
		</div>
		<div id="index2_main_body" class="k_box_size">
			<div class="nav_header">
				<span id="nav_title"></span>
			</div>
			<div id="page_div_wrap" class="page_wrap k_box_size">
				<iframe  id="page_content_ifr" class="page_content_ifr" frameborder="0" style="overflow:visible;height:100%;width:100%;display:block;vertical-align:top;" ></iframe>
			</div>
		</div>
	</div>
</body>
<script type="application/javascript">
	
    function pageLoaded() {
      	var themeIndex = '[(${themeIndex})]';
    	var allOps = $("#theme_ops").children("a").click(function(){
    		$(this).addClass("actived").siblings().removeClass("actived");
    		window.location.href = $B.getHttpHost(ctxPath)+"main/page/"+$(this).attr("id");
    	}).each(function(){
    		var $t = $(this);
    		if($t.attr("id") === themeIndex){
    			$t.addClass("actived").siblings().removeClass("actived");
    		}
    	});
    	$("#user_info").children("._user_name").dropDownList([
    		{
    			text:'个人信息',
    			icon:'fa-address-card-o',
    			click:function(){
    				alert("个人信息");
    			}
    		},{
    			text:'修改密码',
    			icon:'fa-lock',
    			click:function(){
    				alert("修改密码");
    			}
    		},{
    			text:'系统配置',
    			icon:'fa-cog-alt',
    			click:function(){
    				alert("fa-gear");
    			}
    		}
    	]);
    	var menuJson = [(${menuJson})];
    	var currentActivedText; 
    	var $loading;
    	var loadingHtml = "<div class='k_box_size' style='position:absolute;z-index:2147483600;width:100%;height:32px;top:0;left:0;' class='loading'><div class='k_box_size' style='filter: alpha(opacity=50);-moz-opacity: 0.5;-khtml-opacity: 0.5;opacity: 0.5;position:absolute;top:0;left:0;width:100%;height:100%;z-index:2147483600;background:#03369B;'></div><div class='k_box_size' style='width:100%;height:100%;line-height:32px;padding-left:16px;position:absolute;width:100%;height:100%;z-index:2147483611;color:#fff;text-align:center;'><i style='color:#fff;font-size:16px;' class='fa animate-spin fa-spin6'></i><span style='padding-left:5px;font-weight:bold;color:#fff;'>" + $B.config.loading + "</span></div></div>";
		
    	if( menuJson.length > 0){
    		var ifr = $("#page_content_ifr");
    		ifr.on("load",function(){
 				if($loading){
 					$loading.fadeOut(function(){
 						$(this).remove();
 					});
 				}
    		});
    		var leftMenu = $("#index2_menu_ul");
    		var activeTree;
    		var navTitle = $("#nav_title");
    		var banner = navTitle.parent();
    		$("<span class='_alert_msg'>代办<span><span class='_alert_num'>2</span></span></span>").appendTo(banner);
    		$("<span class='_alert_msg'>告警<span><span  class='_alert_num'>5</span></span></span>").appendTo(banner);
    		$("<span class='_alert_msg'>通知<span><span  class='_alert_num'>8</span></span></span>").appendTo(banner);
    		
    		var modleClickFn = function(){
    			var $t = $(this);
    			$t.addClass("actived").siblings().removeClass("actived");
    			if(activeTree){
    				//console.log("destroy >>>>>>");
    				activeTree.destroy();
    			}
    			var treeData = $t.data("mdata");
    			var $div = $("<div></div>").appendTo(leftMenu);    			
    			var txt = treeData.text;
    			var clsIcon = treeData.data.menuIconCss;
    			activeTree = new $B.Menu($div,{
    				data: treeData.children,
    				onClick:function(_data,isParent){
    					if(!isParent){
    						if($loading){
    							$loading.remove();
    						}
    						$loading = $(loadingHtml).insertAfter(ifr);    			
    						var url = $B.getHttpHost(ctxPath) + _data.controller+"/page/"+_data.pageName ;
                        	if(_data.params && _data.params !== ""){
                        		url = url + "?"+ _data.params;
                        	}
                        	ifr[0].src = url;                         	
                        	var txtArr = activeTree.getTreeTxtPath();
                        	txtArr.unshift(txt);                        	
                        	navTitle.html("<i class='fa "+clsIcon+"'></i>" + txtArr.join("<i class='fa fa-angle-right'/>"));                        	
    					}
    				}
    			});    			
    		};
    		var headerMWrap = $("#header_menu_wrap");
        	for(var i = 0, len = menuJson.length ; i < len ;++i){
        		var mData = menuJson[i];
        		var $a =$("<a>"+mData.text+"</a>").appendTo(headerMWrap);
        		$a.click(modleClickFn).data("mdata",mData);
        		if(i === 0){
        			$a.trigger("click");
        		}
        	}
    	}else{
    		$B.error({
    			message:'尚未登录或无访问权限!' ,
    			timeout:3,
    			onClosed:function(){
    				window.location.href = $B.getHttpHost(ctxPath)+"main/page/login";
    			}
    		});	
    	}        
        $("#logout").click(function(){
        	  $B.confirm({                  
                    message: '请确认退出系统？',
                    okFn: function () {
                  	var win = $B.message("正在退出......");
        			$B.request({
        				url:$B.getHttpHost(ctxPath)+"main/logout",
        				data:{},
        				ok:function(msg,data){					
        					window.location.href = $B.getHttpHost(ctxPath)+"main/page/login";
        				},
        				final:function(){
        					win.close();
        				}
        			});
                  }
              });
        });
    };
   
    $(function () {
    	$B.config.curdDatagridOpts.splitColLine = false;//不需要单元格分割线
        pageLoaded();
    });   

</script>
</html>